home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / rodent.zip / MOUSDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1987-10-14  |  3KB  |  72 lines

  1. PROGRAM mousdemo;     { Demo of the mouse unit }
  2.  
  3. USES dos, crt, mouse;
  4.  
  5. CONST hardware = 1;                                  { cursor types }
  6.       software = 0;
  7.       left     = 0;                                 { mouse buttons }
  8.       right    = 1;
  9.  
  10. VAR  theMouse : resetRec;                         { for mouse fcn 0 }
  11.      its      : locRec;                       { for mouse inquiries }
  12.      col, row : integer;
  13.      input    : string [80];
  14.  
  15.  
  16. BEGIN
  17.   CLRSCR;                                        { clear the screen }
  18.   mReset (theMouse);                         { initialize the mouse }
  19.   IF theMouse.exists THEN               { and make sure we have one }
  20.  
  21. { Do the software mouse demo first }
  22.     BEGIN
  23.       WRITELN ('Software cursor:');
  24.       WRITELN ('Demo of a mouse with ',
  25.                 theMouse.nButtons, ' buttons');
  26.       WRITELN ('Move the mouse around and click the left button');
  27.       WRITELN ('Click the right button for hardware mouse demo');
  28.       WRITELN;
  29.       mTextCursor (software, $0000, $0718);        { set s/w cursor }
  30.       mShow;                                       { turn cursor on }
  31.       REPEAT
  32.         mReleased (left, its);                  { check left button }
  33.         IF its.opCount > 0 THEN BEGIN
  34.           mHide;                           { in case screen scrolls }
  35.           WRITELN ('Mouse is at column ', its.column,
  36.                    ', row ', its.row);
  37.           mShow;                                   { cursor back on }
  38.         END;
  39.         mReleased (right, its);                { check right button }
  40.       UNTIL its.opCount > 0;                 { loop if not released }
  41.  
  42. { Now do the hardware mouse demo }
  43.       CLRSCR;
  44.       WRITELN ('Hardware cursor:');
  45.       WRITELN
  46.         ('Move the mouse, click left button');
  47.       WRITELN ('Type something and press Enter');
  48.       WRITELN ('Click right button to end demo');
  49.       mReset (theMouse);                   { clear old mouse status }
  50.       mTextCursor (hardware, 2, 5); { set h/w cursor as small block }
  51.       mShow;                                       { and turn it on }
  52.       REPEAT
  53.         mReleased (left, its);                  { check left button }
  54.         IF its.opCount > 0 THEN BEGIN
  55.           col := its.column DIV 8;          { compute text position }
  56.           row := its.row DIV 8;
  57.           GOTOXY (col, row);                    { move text pointer }
  58.           WRITE ('?');                                     { prompt }
  59.           READLN (input);                           { get the input }
  60.           mMoveto (its.column, its.row);         { restore position }
  61.         END;
  62.         mReleased (right, its);                { check right button }
  63.       UNTIL its.opCount > 0;                 { loop if not released }
  64.  
  65. { Clean up afterwards }
  66.       mTextCursor (hardware, 6, 7); { if graphics board, else 11,12 }
  67.       mReset (theMouse);                       { reinitialize mouse }
  68.       CLRSCR;
  69.     END
  70.   ELSE
  71.     WRITELN ('Mouse not present in system');
  72. END.